<template>
	<view class="">
		<scroll-view scroll-y="true" :style="{'height':scrollHeight}">
			<view class="mt-5" v-if="u_loadmore">
				<u-loadmore status="loading" icon-type="circle" />
			</view>
			<view v-else>
				<view class="m-2 bg-white rounded-20" >
					<view class="today_title px-3 py-2 rounded-top">
						<view class="d-flex j-sb pt">
							<view class="d-flex a-center">
								<view class="mr-1 rounded-50 d-flex user_img j-center a-center">
									<u-icon name="account-fill" color="#ff6b69" size="30"></u-icon>
								</view>
								<view class="">{{order_detail.consignee_item.mobile}}</view>
							</view>
							<view class="d-flex a-center">{{return_detail.label_return_status}}</view>
						</view>
						<view class="d-flex j-sb text-light-muted">
							<view class="">{{order_detail.formated_add_time}}</view>
							<view class="">{{order_detail.order_sn}}</view>
						</view>
					</view>
					<view class="pl-3">
						<view class="border-bottom j-sb py-3" v-for="(item,index) in order_detail.goods_items" :key="index">
							<view class="d-flex">
								<view class="">
									<image class="today_hot rounded-20"  :src="item.img.url" mode=""></image>
								</view>
								<view class="ml-2 flex-1 font-28">
									<view class="ellipsis h_60">{{item.name}}</view>
									<view class="d-flex j-sb pt-2">
										<view class="font-weight">{{item.formated_shop_price}}</view><view class="text-muted j-end mr-3">x{{item.goods_number}}</view>
									</view>
								</view>
							</view>
						</view>
						<view class="py-3">
							<text>共{{order_detail.goods_items.length}}件, </text><text>合计:{{order_detail.formated_total_fee}}</text>
						</view>
					</view>
				</view>
				
				<view class="m-2 px-3 py-2 rounded-20 bg-white beizhu">
					<textarea v-model="comment" placeholder="请输入操作备注"  @input="comment_change" maxlength="139"></textarea>
				</view>
			</view>
		</scroll-view>
		
		<view class="footer"></view>
		<view class="bg-white py-2 w-100 position-fixed bottom-0 btn">
			<button type="warn" @click="confirm_payment">完成维修</button>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				comment:"", // 操作备注
				scrollHeight:0, // 屏幕高度
				u_loadmore:true, // 加载中
				order_detail:"", // 订单详情
				return_id:0 , // 脱出ID
				return_detail:"", // 退货详情
			}
		},
		onReady() {
			let _this=this
			uni.getSystemInfo({
				success(resu) {
					const query = uni.createSelectorQuery()
					query.select('.footer').boundingClientRect()
					console.log(resu)
					query.exec(function(res) {
						_this.scrollHeight = resu.windowHeight - res[0].bottom + 'px';
					})
				}
			})
		},
		methods:{
			// 操作备注
			comment_change(e){
				this.comment=e.detail.value
			},
			confirm_payment(){
				this.$H.post("admin/order/return/operate/finished",{
					return_id:this.return_id,
					action_note:this.comment
				}).then(res=>{
					this.$u.toast("完成维修")
					setTimeout(()=>{
						uni.navigateBack({
							delta:1
						})
					},1000)
					// if(res.data){
					// 	this.$u.toast("完成维修")
					// 	setTimeout(()=>{
					// 		uni.navigateBack({
					// 			delta:1
					// 		})
					// 	},1000)
					// }else{
					// 	this.$u.toast(res.status.error_desc)
					// }
				})
			}
		},
		onLoad(e) {
			this.return_id=e.return_id
			this.order_id=e.order_id
			this.$H.post("admin/orders/detail",{id:e.order_id}).then(res=>{
				this.order_detail=res.data
				this.u_loadmore=false 
			})
			this.$H.post("admin/order/return/detail",{
				return_id:this.return_id
			}).then(res=>{
				this.return_detail=res.data
			})
		}
	}
</script>

<style>
	textarea{
		height: 200upx;
	}
	.user_img{
		width: 40upx;
		height: 40upx;
		background-color: #ffd1d0;
	}
	.today_title{
		background-color: #f6efef;
	}
	.today_hot{
		width: 150upx;
		height: 150upx;
	}
	.h_60{
		height: 90upx;
	}
</style>
